<?php defined('SYSPATH') or die('No direct access allowed.');

class Model_Express_Destination extends ORM
{

    /**
     * @function 获取城市名称
     * @param $ids
     * @return bool
     */
    public static function get_address_title($ids)
    {
        if(!$ids)
        {
            return false;
        }
        $ids=explode(',',$ids);
        foreach ($ids as $k=>$v) {
            if(empty($ids[$k])){
                unset($ids[$k]);
            }
        }
        $ids = join(',',$ids);
        $list = DB::select('cityname')
            ->from('express_destination')
            ->where("id in ($ids)")
            ->execute()->as_array();
        $citynames = '';
        foreach ($list as $v)
        {
            $citynames .= $v['cityname'] . '、';
        }
        mb_internal_encoding("UTF-8");
        $encoding = mb_internal_encoding();
        return St_Functions::mb_rtrim($citynames, "、",$encoding);
    }

    /**
     * @function 获取下级城市、省份
     * @param $pid
     */
    public static function get_address_city_list($pid)
    {
        return DB::select('id','cityname')
            ->from('express_destination')
            ->where('pid','=',$pid)
            ->execute()->as_array();
    }

}